{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import bqplot.pyplot as plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "size = 100\n",
    "scale = 100.\n",
    "np.random.seed(0)\n",
    "x_data = np.arange(size)\n",
    "y_data = np.cumsum(np.random.randn(size)  * scale)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Line Chart"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "fig = plt.figure(title='First Example')\n",
    "plt.plot(y_data)\n",
    "fig"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "This image can be saved by calling the `save_png` function of the `Figure` object:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "fig.save_png()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Line Chart with dates as x data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "dates = np.arange('2005-02', '2005-03', dtype='datetime64[D]')\n",
    "size = len(dates)\n",
    "prices = scale + 5 * np.cumsum(np.random.randn(size))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "fig = plt.figure(title='Changing Styles', background_style={'fill': 'lightgreen'},\n",
    "                 title_style={'font-size': '20px','fill': 'DarkOrange'})\n",
    "axes_options = {'x': {'label': 'Date', 'tick_format': '%m/%d'},\n",
    "                'y': {'label': 'Price', 'tick_format': '0.0f'}}\n",
    "plt.plot(dates, prices, 'b', axes_options=axes_options) # third argument is the marker string\n",
    "fig"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Scatter Chart"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "fig = plt.figure()\n",
    "axes_options = {'x': {'label': 'Date', 'tick_format': '%m/%d'},\n",
    "                'y': {'label': 'Price', 'tick_format': '0.0f'}}\n",
    "\n",
    "plt.scatter(x_data, y_data, colors=['red'], stroke='black')\n",
    "fig"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Histogram"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "fig = plt.figure()\n",
    "plt.hist(y_data)\n",
    "fig"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Bar Chart"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import string\n",
    "\n",
    "fig = plt.figure(padding_x=0)\n",
    "axes_options = {'x': {'label': 'X'}, 'y': {'label': 'Y'}}\n",
    "plt.bar(x=list(string.ascii_uppercase), y=np.abs(y_data[:20]), axes_options=axes_options)\n",
    "fig"
   ]
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
